package com.gee.spring.boot.starter.opengemini.core.query.segment;


import static com.gee.spring.boot.starter.opengemini.core.constant.StrConstant.SPACE;
import static com.gee.spring.boot.starter.opengemini.core.enums.SqlKeyword.LIMIT;
import static com.gee.spring.boot.starter.opengemini.core.enums.SqlKeyword.OFFSET;

/**
 * @author gepengjun
 * @since 2024/4/28 17:17
 */
public class LimitOffsetSegment implements ISqlSegment{


    private Long limit;

    private Long offset;

    public LimitOffsetSegment() {
    }

    public void setLimit(Long limit) {
        this.limit = limit;
    }

    public void setOffset(Long offset) {
        this.offset = offset;
    }

    @Override
    public String getSqlSegment() {
        StringBuilder sqlSegment = new StringBuilder();
        if (limit != null){
            sqlSegment.append(LIMIT.getKeyword()).append(SPACE).append(limit);
        }
        if (offset != null){
            sqlSegment.append(SPACE).append(OFFSET.getKeyword()).append(SPACE).append(offset);
        }
        return sqlSegment.toString();
    }
}
